package me.fung.rem.app

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import me.fung.wubi.repo.configClientID
import org.jasypt.util.password.ConfigurablePasswordEncryptor
import org.jasypt.util.password.PasswordEncryptor
import org.jasypt.util.text.BasicTextEncryptor
import org.jasypt.util.text.TextEncryptor

object GlobalState {

    fun textEncryptor(password: String): TextEncryptor {
        return BasicTextEncryptor().apply {
            setPassword(password)
        }
    }

    fun passwordEncryptor(): PasswordEncryptor = ConfigurablePasswordEncryptor().apply {
        setAlgorithm("MD5")
        setPlainDigest(true)
        setStringOutputType("hexadecimal") //以MD5的16进制表示
    }
}

fun encryptor(): TextEncryptor {
    return GlobalState.textEncryptor(configClientID)
}